#ifndef WIFICONTROLLER_H
#define WIFICONTROLLER_H

#include <QObject>
#include <QProcess>
#include <QTimer>

class WifiController : public QObject
{
    Q_OBJECT
public:
    explicit WifiController(QObject *parent = 0);
    void get_WifiInfo();
    void connect_Wifi(QString ESSID,QString psw);
    void connect_Wifi(QString ESSID);
    void disconnect_Wifi();
    void forget_Wifi(QString ESSID);
    bool has_Password(QString ESSID);
    QString m_curESSID;
    bool isConnected;
signals:
    void refreshWifiInfo(QStringList);
    void hasConnected();
public slots:
    void on_processFinished(int exitCode, QProcess::ExitStatus exitStatus);
    void on_timeOut();
    void on_needLoopWifiInfo();
private:
    QProcess *m_process;
    enum CurAction { readAllInfo,
                     connectOne};
    CurAction m_curAction;

    QTimer *m_timeOutTimer;
    QTimer *m_wifiInfoLoopTimer;
    bool isConnectting;

};

#endif // WIFICONTROLLER_H
